from fastapi import FastAPI, Request
import uvicorn

# 创建app对象
app = FastAPI()


# 路由函数（路径函数）
@app.get("/")
async def home(request: Request):
    headers = request.headers.items()
    query_params = request.query_params.items()
    cookies = request.cookies.items()
    path_params = request.path_params.items()

    message = """
    请求头信息： {0}
    请求参数： {1}
    cookies： {2}
    路径参数：{3}
    """.format(
        headers, query_params, cookies, path_params
    )
    print(message)

    return message


if __name__ == "__main__":
    uvicorn.run("main:app", host="127.0.0.1", port=8000, reload=True)
